import java.io.File;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RenameDemo04 {
    public static void main(String[] args) {
        String path = "F:\\IdeaProjects\\MyJava230203\\day28\\dir\\movie";
        File file = new File(path);// 创建抽象的File对象
        File[] files = file.listFiles();// 拿到目录的所有文件 [三体.avi,即日快乐.明日快乐.avi]
        Pattern compile = Pattern.compile("(.*)\\.(.*)");
        for (File f : files) {
            String name = f.getName();//三体.avi
            Matcher matcher = compile.matcher(name);
            if (matcher.find()) {  String path1 = "F:\\IdeaProjects\\MyJava230203\\day28\\dir\\movie\\1.txt";
                // 通过正则把path1的文件的目录提取出来，文件的名字 后缀名
                System.out.println(matcher.group(1) + "-----" + matcher.group(2));
                f.renameTo(new File(path + File.separator + matcher.group(1) + "_典藏版." + matcher.group(2)));
            }
        }


//        String name = "1我爱中国2";
//        String name = "123我爱中国2";
//        String name = "123我爱中国234";
//        String name = "我爱中国234";
//        String regex = "\\d*.*\\d*";
//        boolean matches = Pattern.matches(regex, name);
//        System.out.println(matches);


        String desc = "我今年22岁";

//        // 创建Pattern对象
//        Pattern compile = Pattern.compile("(.*?)(\\d+).*");
//        // 通过Pattern对象创建matcher对象
//        Matcher matcher = compile.matcher(desc);
//        if (matcher.find()) {
//            System.out.println(matcher.group(0));
//            System.out.println(matcher.group(1));
//            System.out.println(matcher.group(2));
//        } else {
//            System.out.println("没匹配上");
//        }




    }
}
